<?php
/*
 * Aclass_nav 导航类
 * 2010-07-08
 * http://www.abans.cn		abans@qq.com
 */
class Aclass_enum{
	function  __construct() {
	}
	function cache_name($key){
		return 'Aenum:'.$key;
	}
	//获取枚举数据 (返回数组)
	function data($key){
		$data = $this->model($key);
		return Afun_obj_arr(json_decode($data['data']));
	}
	function arr($key){
		return Afun_obj_arr($this->data($key));
	}
	function model($key){
		$data = Afun_cache_get($this->cache_name($key));
		if(empty($data)){
			$enum = Afun_db()->model(Acan_table_enum);
			if(is_numeric($key)){
				$data = $enum->findPk($key);
			}else{
				$data = $enum->find("code = '$key'");
			}
			Afun_cache_set($this->cache_name($key),$data,3600);
		}
		return $data;
	}
	function cache_del($id,$name){
		Afun_cache_rm($this->cache_name($id));
		Afun_cache_rm($this->cache_name($name));
	}


}

?>
